package de.koller.worlders.engine.entity.zone;

import de.koller.worlders.engine.entity.mo.grav.Gravitron;
import de.koller.worlders.engine.tiles.ITile;
import de.koller.worlders.engine.tiles.data.ITileCreator;
import de.koller.worlders.render.VisualMap;
import de.koller.worlders.render.visual.DisplayRenderObject;

public class GravitronZone extends ZoneEffect {
	public static final int GEN_ID = 16;
	
	public static final ITileCreator GEN_INSTANCE = new ITileCreator() {
		@Override public ITile newInstance() {
			return new Zone().addEffect( new GravitronZone() );
		}
		
		@Override public DisplayRenderObject getIcon() { return VisualMap.gravitron; }
		@Override public String getName() { return "Gravitron"; }
	};
	
	private Gravitron gravitron;
	
	protected GravitronZone() {}
	
	@Override
	public void init( Zone z ) {
		super.init( z );
			
//		zone.setTextureRep( new TextureRep( "data/tiles.png", 256, 0, 32, 32 ) );
		z.getTile().setVisual( VisualMap.gravitron );
		
		//@todo nicht hinzufügen wenn in vorschau beim editor
		float tx = z.getPosition().getXi() + .5f;
		float ty = z.getPosition().getYi() + .5f;
		gravitron = new Gravitron( tx, ty );
		z.root.getEntityContainer().gravitrons.add( gravitron );
	}

	@Override
	public void release() {
		super.release();
		
		zone.root.getEntityContainer().gravitrons.remove( gravitron );
	}
	
}
